package com.itheima.mapper.login;

import com.itheima.domain.UserInfo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * 用户 持久层 接口
 */
public interface LoginMapper {

    //通过账号和密码查找用户
    @Select("select * from users where username=#{uname} and password=#{pwd}")
    UserInfo findByUsernameAndPwd(@Param("uname") String username, @Param("pwd") String password);

    //查找所有
    List<UserInfo> findAll();

    //通过邮箱和密码查找用户
    @Select("select * from users where email=#{email} and password=#{pwd}")
    UserInfo findByEmailAndPwd(@Param("email") String username, @Param("pwd") String password);

    //修改密码
    @Update("update users set password=#{pwd} where id=#{id}")
    void updatePwd(@Param("id") String id,@Param("pwd") String newPwd);

    //查看开启关闭
    @Select("select status from users where id=#{id}")
    String findStatus(String id);
}
